<div class="jpform">
    <ul class="nav nav-pills row" role="tablist">
       
        <li class="active"><a href="/?home/cartlist"  ><span class="glyphicon glyphicon-shopping-cart"></span>购物车<span class="badge" id="cartcount"><?php echo $cart_count;?></span></a></li>
        <li><a href="/?home/clear_cart" class="alert-danger"><span class="glyphicon glyphicon-remove"></span>清空购物车</a></li>
        <li style="margin-top: 3px;">
<form class="form-inline" role="form" action="/index.php?<?php echo $jp_arg['c'];?>/search"  method="post">
    <input type="hidden" name="<?php echo $jp_arg['c'];?>/<?php echo $jp_arg['a'];?>"/>
  <div class="form-group">
    <label for="base_name" class="sr-only">商品名称</label>
    <input type="text" class="form-control" value="<?php if(isset($jp_arg['base_name']))echo $jp_arg['base_name'];?>" name="base_name" id="base_name" placeholder="商品名称">
  </div>
    <div class="form-group">
             <?php if(isset($pinfo)){?>
 <?php foreach($pinfo as $k=>$val){?>
     <?php if($k==0){?>
     <select class="form-control col-md-1 col-xs-3 parent_id" name="parent_id[]">
      <option value="0">顶级分类</option>
 
          <?php foreach($val["data"] as $value){?>
         
          <option value="<?php echo $value['id'];?>" <?php if($value["id"]==$val["selected"]) echo "selected";?> ><?php echo $value['base_name'];?></option>
        
  
         <?php }?>
  </select>
     <?php }else{?>
     <span class="menuchildrenall">  
         <select class="form-control col-md-1 col-xs-4 menuchildren"  onchange="menuselectchange(this)" name="parent_id[]">
          <option value="-1">请选择分类</option>
    
          <?php foreach($val["data"] as $value){?>
           <option value="<?php echo $value['id'];?>" <?php if($value["id"]==$val["selected"]) echo "selected";?> ><?php echo $value['base_name'];?></option>
          <?php }?>
       
         
  </select>

</span>
     <?php }?>
     <?php }?>
<?php }?>
    </div>
    <button type="submit" name="search" class="btn btn-default">搜索</button>
  <script>
      function menuselectchange(obj){
             var cid=$(obj).val();

             
         
             var thisobj=$(obj).parent();
                if(cid>0){
                 
               
              
                  $.post("?goodcate/public_get_children",{"parent_id":cid},function(data){
                  $(".menuchildrenall").each(function(){
                      if($(this).index()>thisobj.index()){
                          $(this).remove();
                      }
                  });
                  text=data.replace(/(^\s*)|(\s*$)/g,'');
                  if(text.length>0){
                  $(".menuparent").append(data);
                  }
                 
      });
             }

        }
    $('.parent_id').bind('change', function () {
      var cid=$(this).val();
      var parent=$(this).parent();
    
      if(cid!=0){
      
      $.post("?goodcate/public_get_children",{"parent_id":cid},function(data){
          $(".menuchildrenall").remove();
          parent.append(data);
         
      });
    }else{
      
        $(".menuchildrenall").remove();
    }
    });
    
  </script>
</form>
        </li>
         </ul>
     </div>